import React, { useEffect, useState } from 'react'
import store from '../redux/store'

export default function Count() {
  //   const [x, setX] = useState(0)
  //   useEffect(() => {
  //     store.subscribe(() => {
  //       setX((x) => {
  //         return x + 1
  //       })
  //     })
  //   }, [])
  return (
    <div>
      <p>{store.getState().count}</p>
      <button
        onClick={() => {
          store.dispatch({ type: 'increment' })
        }}
      >
        +
      </button>
      <button
        onClick={() => {
          store.dispatch({ type: 'decrement' })
        }}
      >
        -
      </button>
    </div>
  )
}
